<?php


namespace App\Services;


use App\Models\Message;

class MessageService extends BaseService
{
    /**
     * 站内信
     *
     * @param string $title 标题
     * @param string $content 内容
     * @param string $acceptUuid 接收者UUID
     * @throws \Exception
     */
    public static function fallbackUmeng($title, $content, $acceptUuid)
    {
        if (empty($title) || empty($content) || empty($acceptUuid)) {
            throw new \Exception('标题，内容和接收者uuid必传');
        }

        $builder                = [];
        $builder['title']       = trim($title);
        $builder['content']     = trim($content);
        $builder['read']        = Message::READ_NO; // 未读
        $builder['send_uuid']   = 1; // 系统发送
        $builder['accept_uuid'] = $acceptUuid;
        $builder['flag']        = Message::FLAG_SYSTEM_FRONT; // 系统推送给前台

        Message::create($builder);
    }
}